<template>
  <NavHeader />
  <!--  -->
  <swiper :modules="[Autoplay, Pagination]" :slides-per-view="1"
    :autoplay="{ delay: 3000, disableOnInteraction: false, pauseOnMouseEnter: true }" :speed="1000" :loop="true"
    pagination class="mySwiper" @slideChange="onSlideChange" @mouseenter="pauseSwiper" @mouseleave="resumeSwiper"
    ref="swiperRef">
    <swiper-slide v-for="(image, index) in images" :key="index" :class="{ animate: animateIndex === index }">
      <img :src="image" alt="轮播图" />
      <!-- <div class="countdown">{{ countdown }}</div> -->
      <div class="ai-list flex-wrap flex-jsc">
        <AiList />
      </div>
    </swiper-slide>
  </swiper>

  <div class="top-wrap">
    <img src="@/assets/img/data-show.png" class="data-show">
    <!-- 智能解决方案 -->
    <div>
      <div class="solution">
        <h2>智能解决方案</h2>
        <p>为客户提供整套的智能制造工程系统解决方案</p>
      </div>
      <div class="marquee-wrapper">
        <div v-for="(row, rowIndex) in imageRows" :key="rowIndex" class="marquee-row"
          :class="{ paused: pausedRows[rowIndex] }" @mouseenter="pauseRow(rowIndex)" @mouseleave="resumeRow(rowIndex)">
          <div class="marquee-track" :style="{ animationDuration: row.speed + 'ms' }">
            <!-- 图片重复两遍实现无限滚动 -->
            <div v-for="(img, i) in row.images.concat(row.images)" :key="i" class="marquee-img-wrapper">
              <img :src="img" class="marquee-img" />
              <div class="overlay">
                <button class="details-btn">查看详情</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- 方案亮点 -->
  <div>
    <div class="solution">
      <h2>方案亮点</h2>
      <p>APS、IPS、图纸助手</p>
    </div>
    <div class="scheme flex-jsc">
      <div class="flex-jc cursor" @click="active = index" v-for="(item, index) in schemeList" :key="index">
        <img :src="active == index ? item.activeUrl : item.img">
        <div>{{ item.name }}</div>
      </div>
    </div>
    <FadeInSection animation="fade-down" v-if="active === 0">
      <div class="flex solution-wrap">
        <div class="solution-content">
          <div class="flex">
            <div class="num">01</div>
            <div class="title">APS</div>
          </div>
          <div>
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点一</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
          <div class="mt30">
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点二</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
          <div class="mt30">
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点三</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
        </div>
        <img src="@/assets/img/aps-img.png" alt="" class="solution-img">
      </div>
    </FadeInSection>
    <FadeInSection animation="fade-down" v-if="active === 1">
      <div class="flex solution-wrap">
        <div class="solution-content">
          <div class="flex">
            <div class="num">02</div>
            <div class="title">IPS</div>
          </div>
          <div>
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点一</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
          <div class="mt30">
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点二</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
          <div class="mt30">
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点三</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
        </div>
        <img src="@/assets/img/ips-img.png" alt="" class="solution-img">
      </div>
    </FadeInSection>
    <FadeInSection animation="fade-down" v-if="active === 2">
      <div class="flex solution-wrap">
        <div class="solution-content">
          <div class="flex">
            <div class="num">03</div>
            <div class="title">图纸助手</div>
          </div>
          <div>
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点一</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
          <div class="mt30">
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点二</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
          <div class="mt30">
            <div class="flex-ac">
              <img src="@/assets/img/true-icon.png">
              <div class="subtitle">方案亮点三</div>
            </div>
            <div class="desc">亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述亮点描述</div>
          </div>
        </div>
        <img src="@/assets/img/tuzhi-img.png" alt="" class="solution-img">
      </div>
    </FadeInSection>
  </div>
  <!-- 合作客户 -->
  <div>
    <div class="solution">
      <h2>合作客户</h2>
      <p>获得知名客户一致认可</p>
    </div>
    <FadeInSection animation="fade-up">
      <img src="@/assets/img/partner.png" class="partner" alt="合作客户">
    </FadeInSection>
  </div>
  <!-- 荣誉奖项 -->
  <div>
    <div class="solution">
      <h2>荣誉奖项</h2>
      <p>为客户提供整套的智能制造工程系统解决方案</p>
    </div>
    <FadeInSection animation="zoom-in">
      <div class="honor-wrap">
        <div class="honor-list1">
          <img src="@/assets/img/honor/honor1.png" alt="">
          <img src="@/assets/img/honor/honor2.png" alt="">
          <img src="@/assets/img/honor/honor3.png" alt="">
          <img src="@/assets/img/honor/honor4.png" alt="">
          <img src="@/assets/img/honor/honor5.png" alt="">
        </div>
        <div class="honor-list2">
          <img src="@/assets/img/honor/honor6.png" alt="">
          <img src="@/assets/img/honor/honor7.png" alt="">
          <img src="@/assets/img/honor/honor8.png" alt="">
          <img src="@/assets/img/honor/honor9.png" alt="">
        </div>
      </div>
    </FadeInSection>

  </div>
  <!-- 底部 -->
  <PageFoot />

</template>

<script setup>
import { Swiper, SwiperSlide } from 'swiper/vue';
import { Autoplay, Pagination, Navigation } from 'swiper/modules';
import NavHeader from '@/components/NavHeader.vue';
import PageFoot from '@/components/PageFoot.vue';
import FadeInSection from '@/components/FadeInSection.vue';
import AiList from '@/components/AiList.vue';
import { ref, onMounted } from 'vue';
import 'swiper/css';
import 'swiper/css/pagination';
import 'swiper/css/navigation';

const images = [
  new URL('@/assets/img/banner1.png', import.meta.url).href,
  new URL('@/assets/img/banner1.png', import.meta.url).href,
  new URL('@/assets/img/banner1.png', import.meta.url).href,

];

let active = ref(0)

let scrollList = [
  new URL('@/assets/img/img1.png', import.meta.url).href,
  new URL('@/assets/img/img2.png', import.meta.url).href,
  new URL('@/assets/img/img3.png', import.meta.url).href,
  new URL('@/assets/img/img4.png', import.meta.url).href,
  new URL('@/assets/img/img5.png', import.meta.url).href,
  new URL('@/assets/img/img1.png', import.meta.url).href,
]

const schemeList = ref([
  { name: "APS", img: new URL('@/assets/img/aps.png', import.meta.url).href, activeUrl: new URL('@/assets/img/aps-active.png', import.meta.url).href },
  { name: "IPS", img: new URL('@/assets/img/ips.png', import.meta.url).href, activeUrl: new URL('@/assets/img/ips-active.png', import.meta.url).href },
  { name: "图纸助手", img: new URL('@/assets/img/tuzhi.png', import.meta.url).href, activeUrl: new URL('@/assets/img/tuzhi-active.png', import.meta.url).href }

])

const imageRows = [
  {
    speed: 30000, // 每轮滚动时间（越大越慢）
    images: scrollList,
  },
  {
    speed: 20000,
    images: scrollList,
  },
  {
    speed: 40000,
    images: scrollList,
  },
]

const pausedRows = ref([false, false, false])

function pauseRow(index) {
  pausedRows.value[index] = true
}

function resumeRow(index) {
  pausedRows.value[index] = false
}


const swiperRef = ref(null)
const animateIndex = ref(0)
const countdown = ref(3)
let timer = null

const startCountdown = () => {
  countdown.value = 3
  clearInterval(timer)
  timer = setInterval(() => {
    countdown.value--
    if (countdown.value === 0) {
      swiperRef.value.swiper.slideNext()
    }
  }, 1000)
}

const onSlideChange = (swiper) => {
  animateIndex.value = swiper.realIndex
  // startCountdown()
}

const pauseSwiper = () => {
  swiperRef.value?.swiper?.autoplay?.stop()
}
const resumeSwiper = () => {
  swiperRef.value?.swiper?.autoplay?.start()
}

onMounted(() => {
  // startCountdown()
})
</script>

<style scoped lang="less">
.mySwiper {
  width: 100%;
  height: 700px;
  position: relative;

  .ai-list {
    width: 250px;
    position: absolute;
    top: 42%;
    left: 21%;
    flex-wrap: wrap;
    gap: 10px;
    z-index: 2;
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    transition: transform 1s ease;
  }

  .swiper-slide.animate img {
    animation: zoom-out 5s forwards;
  }

  @keyframes zoom-out {
    0% {
      transform: scale(1.3);
    }

    100% {
      transform: scale(1);
    }
  }

  .countdown {
    position: absolute;
    bottom: 20px;
    right: 30px;
    font-size: 24px;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 4px;
    z-index: 2;
  }
}

.data-show {
  width: 1311px;
  height: 110px;
  margin: 0px auto 75px;
  display: block;
}

.top-wrap {
  background: rgba(247, 251, 255, 1);
  padding-bottom: 50px;
  padding-top: 70px;
  margin-bottom: 100px;
}

.marquee-wrapper {
  display: flex;
  flex-direction: column;
  gap: 50px;
  overflow: hidden;
  margin-top: 30px;

  .marquee-row {
    overflow: hidden;
    width: 100%;
    position: relative;
    height: 234px;

    .marquee-track {
      display: flex;
      width: max-content;
      height: 100%;
      animation: scroll-left linear infinite;

      .marquee-img-wrapper {
        position: relative;
        height: 100%;
        width: 319px;
        margin-right: 30px;
        display: flex;
        align-items: center;
        justify-content: center;

        .marquee-img {
          height: 100%;
          width: 319px;
          object-fit: contain;
          display: block;
          transition: transform 0.3s ease;
          cursor: pointer;
        }
      }
    }
  }
}

/* 动画关键帧 */
@keyframes scroll-left {
  0% {
    transform: translateX(0%);
  }

  100% {
    transform: translateX(-50%);
  }
}

/* 鼠标悬浮暂停动画 */
.paused .marquee-track {
  animation-play-state: paused !important;
}

/* 毛玻璃覆盖层 */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(6px);
  background-color: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* 鼠标悬浮时显示 overlay */
.marquee-img-wrapper:hover .overlay {
  opacity: 1;
  pointer-events: auto;
}

/* 查看详情按钮样式 */
.details-btn {
  padding: 6px 14px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.details-btn:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

.solution-wrap {
  width: 62%;
  margin: 57px auto 80px;

  .solution-content {
    width: 441px;

    &>.flex {
      margin-bottom: 20px;
    }

    .subtitle {
      margin-left: 8px;
    }

    .desc {
      font-size: 17px;
      margin-left: 35px;
    }

    .num {
      font-size: 32px;
      font-weight: 700;
      color: rgba(0, 108, 255, 1);
      margin-right: 10px;
    }

    .title {
      font-size: 28px;
      font-weight: 700;
    }
  }


  .solution-img {
    width: 617px;
    height: 363px;
    border-radius: 20px;
    margin-left: 40px;
    background: #000;
  }
}


.solution {
  text-align: center;
  font-weight: 400;

  & h2 {
    font-size: 32px;
    color: #000;
  }

  & p {
    font-size: 15px;
    color: rgba(88, 95, 109, 1);
    margin-top: 11px;
  }
}

.partner {
  width: 1125px;
  height: 441px;
  display: block;
  margin: 29px auto 51px;
}

.honor-wrap {
  margin: 0 auto;
  width: 57%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 90px;

  .honor-list1,
  .honor-list2 {
    width: 1100px;
    display: flex;
    margin-top: 30px;
    justify-content: space-between;
  }

  .honor-list2 {
    width: 871px;
  }
}

.scheme {
  width: 50%;
  margin: 42px auto 57px;
  font-size: 26px;
  gap: 10px;

  &>div {
    border: 1px solid #cacfd6;
    padding: 12px 0px;
    border-radius: 14px;
    text-align: center;
    width: 268px;

    img {
      margin-right: 15px;
    }

    &:nth-child(1) img {
      width: 39px;
      height: 36px;
    }

    &:nth-child(2) img {
      width: 37px;
      height: 30px;
    }

    &:nth-child(3) img {
      width: 34px;
      height: 34px;
    }
  }
}
</style>
